package blog.util;


import blog.util.email.Email;

import java.util.ArrayList;
import java.util.List;

public class EmailVerifyCode {
    public static void send(String receiverEmail, String code) throws Exception {
        String userName = "937503784@qq.com"; // 发件人邮箱
        String password = "ctzeyhvmqnvnbdgj"; // 发件人密码
        String smtpHost = "smtp.qq.com"; // 邮件服务器

        String to = receiverEmail; // 收件人，多个收件人以半角逗号分隔
        String cc = ""; // 抄送，多个抄送以半角逗号分隔
        String subject = "博客用户个人验证码"; // 主题
        String body = "你的验证码是" + code; // 正文，可以用html格式的哟
        //List<String> attachments = Arrays.asList("D:\\tmp\\1.png", "D:\\tmp\\2.png");  附件的路径，多个附件也不怕
        List<String> attachments = new ArrayList<>();
        Email email = Email.entity(smtpHost, userName, password, to, cc, subject, body, attachments);

        email.send(); // 发送！
    }

    public static void main(String[] args){

        try {
            EmailVerifyCode.send("13145211410@163.com", "2654");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}
